package com.aldobucchi.x.mx.collections.IList.op
{


	import mx.collections.ArrayCollection;
	import mx.collections.IList;
	
	import com.aldobucchi.utils.AbstractTest;
	import com.aldobucchi.utils.IOperator;


	public class ListFieldProjectionOpTest extends AbstractTest
	{
		
		
		private static var a:Object = { a:"aa", b:"ab", c:"ac" };
		
		private static var b:Object = { a:"ba", b:"bb", c:"bc" };
		
		private static var c:Object = { a:"ca", b:"cb", c:"cc" };
		

		
		
		public function testMisc( ):void
		{
		
			var input:IList = new ArrayCollection( );
			
			var outA:IList = new ArrayCollection( );
			var outB:IList = new ArrayCollection( );
			var outC:IList = new ArrayCollection( );
			
			var opA:IOperator = new ListFieldProjectionOp( input, outA, "a" );
			var opB:IOperator = new ListFieldProjectionOp( input, outB, "b" );
			var opC:IOperator = new ListFieldProjectionOp( input, outC, "c" );
			
			
			
			assertEquals( outA.length, 0 );
			assertEquals( outB.length, 0 );
			assertEquals( outC.length, 0 );
			
			
			
			assertContainersEqual( outA, [] );
			assertContainersEqual( outB, [] );
			assertContainersEqual( outC, [] );
			
			
			
			input.addItem( a );
			
			assertContainersEqual( outA, [ "aa" ] );			
			assertContainersEqual( outB, [ "ab" ] );			
			assertContainersEqual( outC, [ "ac" ] );			
			
			

			input.addItem( b );
			
			assertContainersEqual( outA, [ "aa", "ba" ] );			
			assertContainersEqual( outB, [ "ab", "bb" ] );			
			assertContainersEqual( outC, [ "ac", "bc" ] );			
		
		

			input.addItem( c );
		
			assertContainersEqual( outA, [ "aa", "ba", "ca" ] );			
			assertContainersEqual( outB, [ "ab", "bb", "cb" ] );			
			assertContainersEqual( outC, [ "ac", "bc", "cc" ] );		
			
			
			
			input.removeAll();	
			
			assertContainersEqual( outA, [] );
			assertContainersEqual( outB, [] );
			assertContainersEqual( outC, [] );		
			
			
				
				
			input.addItem( a );
			
			assertContainersEqual( outA, [ "aa" ] );			
			assertContainersEqual( outB, [ "ab" ] );			
			assertContainersEqual( outC, [ "ac" ] );	
							
		}
		
	}
}